package net.xju.dao;

import net.xju.common.utils.JdbcUtilsV1;
import net.xju.entity.Appointment;

import java.util.List;

public class AppointmentDao {
    public List<Appointment> getAppointmentsByConsultantId(int consultantId) {
        String sql = "SELECT id, user_id, consultant_id, appointment_time FROM Appointments WHERE consultant_id = ?";
        return JdbcUtilsV1.executeQuery(JdbcUtilsV1.getConnection(), Appointment.class, sql, consultantId);
    }

    public boolean insert(Appointment appointment) {
        String sql = "INSERT INTO Appointments (user_id, consultant_id, appointment_time) VALUES (?,?,?)";
        int i = JdbcUtilsV1.executeUpdate(sql, appointment.getUserId(), appointment.getConsultantId(), appointment.getAppointmentTime());
        return i > 0;
    }
}